﻿/*CLIENTAMF.NET - an open-source .NET alternative to Macromedia's .NET Flash Remoting Client
Copyright (C) 2010 Kiko Qiu - http://hi.baidu.com/kikoqiu

This project is based on the open-source project of AMF.NET, 
Part of the code is just a copy from it. You may check it out from sourceforge.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using kikoqiu;

namespace ClientAmfNetTest
{
    public partial class Form1 : Form
    {
        kikoqiu.AmfClient ac = new AmfClient();
        public Form1()
        {
            InitializeComponent();
            ac.Gateway = "http://pyamf.appspot.com/gateway/shell/";
            try
            {
                object ret = ac.Call("shell", "startup", new object[] { });
                textBox1.Text += ret;
            }
            catch(Exception e)
            {
                MessageBox.Show("Init Error:" + e.ToString());
                Close();
            }
        }

        private void textBox2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                EvalCode();
            }
        }

        private void EvalCode()
        {
            object ret = ac.Call("shell", "evalCode", new object[] { textBox2.Text });
            string s = ret as string;
            s = s.Replace("\n", "\r\n");
            textBox1.Text += s;
            textBox2.Text = "";
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                e.Handled = true;
            }
        }
    }
}
